package choreganizer;

import javax.swing.*;




public class ScheduleData
extends JLabel
implements Cloneable
{
	
	private static final String newLine = "\n";
	
	private String id = "";
	private String choreID = "";
	private String dateAdded = "";
	private String startDate = "";
	
	private ScheduleTypes.YearTypes yearType;
	private ScheduleTypes.MonthTypes monthType;
	private ScheduleTypes.DayTypes dayType;
	private ScheduleTypes.TimeTypes timeType;
	private ScheduleTypes.AlertTypes alertType;
	
	private String[] schedYear;
	private String[] schedMonth;
	private String[] schedDay;
	private String[] schedTime;
	

	
	
	public void setID(String s)
	{
		setText(s);
		id = s;
	}
	
	public String getID()
	{
		return id;
	}
	
	public void setChoreID(String s)
	{
		choreID = s;
	}
	
	public String getChoreID()
	{
		return choreID;
	}
	
	public void setDateAdded(String s)
	{
		dateAdded = s;
	}
	
	public String getDateAdded()
	{
		return dateAdded;
	}
	
	public void setStartDate(String s)
	{
		startDate = s;
	}
	
	public String getStartDate()
	{
		return startDate;
	}
	
	
	
	
	public void setYearType(ScheduleTypes.YearTypes yt)
	{
		yearType = yt;
	}
	
	public ScheduleTypes.YearTypes getYearType()
	{
		return yearType;
	}
	
	public void setMonthType(ScheduleTypes.MonthTypes mt)
	{
		monthType = mt;
	}
	
	public ScheduleTypes.MonthTypes getMonthType()
	{
		return monthType;
	}
	
	public void setDayType(ScheduleTypes.DayTypes dt)
	{
		dayType = dt;
	}
	
	public ScheduleTypes.DayTypes getDayType()
	{
		return dayType;
	}
	
	public void setTimeType(ScheduleTypes.TimeTypes ht)
	{
		timeType = ht;
	}
	
	public ScheduleTypes.TimeTypes getTimeType()
	{
		return timeType;
	}
	
	public void setAlertType(ScheduleTypes.AlertTypes at)
	{
		alertType = at;
	}
	
	public ScheduleTypes.AlertTypes getAlertType()
	{
		return alertType;
	}
	
	
	
	
	public void setScheduledYear(String[] s)
	{
		schedYear = s;
	}
	
	public String[] getScheduledYear()
	{
		return schedYear;
	}
	
	public void setScheduledMonth(String[] s)
	{
		schedMonth = s;
	}
	
	public String[] getScheduledMonth()
	{
		return schedMonth;
	}
	
	public void setScheduledDay(String[] s)
	{
		schedDay = s;
	}
	
	public String[] getScheduledDay()
	{
		return schedDay;
	}
	
	public void setScheduledTime(String[] s)
	{
		schedTime = s;
	}
	
	public String[] getScheduledTime()
	{
		return schedTime;
	}
	
	
	
	
	public String arrayToString(String[] str)
	{
		StringBuilder sb = new StringBuilder();
		
		if (str != null)
		{
			for (String s: str)
			{
				sb.append(s + ", ");
			}
		}
		
		return sb.toString();
	}
	
	public String toXMLString()
	{
		StringBuilder sb = new StringBuilder();
		
		sb.append("<item id=\"" + id + "\" dateAdded=\"" + dateAdded + "\">" + newLine);
		sb.append("  <choreID>" + choreID + "</choreID>" + newLine);
		sb.append("  <scheduling start=\"" + startDate + "\">" + newLine);
		sb.append("     <year type=\""  + yearType  + "\">" + arrayToString(schedYear)  + "</year>" + newLine);
		sb.append("     <month type=\"" + monthType + "\">" + arrayToString(schedMonth) + "</month>" + newLine);
		sb.append("     <day type=\""   + dayType   + "\">" + arrayToString(schedDay)   + "</day>" + newLine);
		sb.append("     <time type=\""  + timeType  + "\">" + arrayToString(schedTime)  + "</time>" + newLine);
		sb.append("  </scheduling>" + newLine);
		sb.append("  <alert type=\"" + alertType + "\"></alert>" + newLine);
		sb.append("</item>" + newLine);
		
		return sb.toString();
	}
	
	public String toString()
	{
		return id;
	}
	
	public Object clone( )  
	{
		try 
		{
			return super.clone( );
		} 
		catch (CloneNotSupportedException ex) 
		{
			throw new InternalError(ex.toString( ));
		}
	}
	
	
}